package com.lb.pdm.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {

    /**
     * 添加 Mybatis Plus 拦截器
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

        // 1. 添加分页插件
        // (你需要根据你的数据库类型来指定 DbType，例如 DbType.MYSQL)
        PaginationInnerInterceptor pageInterceptor = new PaginationInnerInterceptor(DbType.MYSQL); 
        
        // (可选) 设置单个请求的最大分页数，-1 表示不限制
        pageInterceptor.setMaxLimit(100L); // 比如，防止恶意查询，限制每页最多100条
        
        interceptor.addInnerInterceptor(pageInterceptor);


        return interceptor;
    }
}